# webp2jpg
from PIL import Image
import os


def webp2jpg(webp_folder, jpg_folder):
	if not os.path.exists(jpg_folder):
		os.makedirs(jpg_folder)
	for name in os.listdir(webp_folder):
		if not name.endswith('.webp'):
			continue
		print('processing {}'.format(name))
		webp_path = os.path.join(webp_folder, name)
		jpg_path = os.path.join(jpg_folder, name.replace('.webp', '.jpg'))
		# load image
		img = Image.open(webp_path)
		img.save(jpg_path, 'JPEG')


if __name__ == '__main__':
	webp2jpg('./javdatabase', './javdatabase_jpg')
